package ttsolver.solver;

import ilog.concert.IloException;
import ilog.concert.IloLinearNumExpr;
import ilog.concert.IloNumVar;
import ilog.concert.IloRange;

public class OptRow {
	private IloLinearNumExpr expr;
	private IloRange range;

	public OptRow() throws IloException{

	}
	
	public void addTerm(double coef, IloNumVar var) throws IloException{
		expr.addTerm(coef, var);
	}
	
	public IloLinearNumExpr getExpr() {
		return expr;
	}

	public void setExpr(IloLinearNumExpr expr) {
		this.expr = expr;
	}
	
	public void equal(OptK lp, String name, double rhs) throws IloException{
		this.range = lp.getModel().range(0, rhs);
		IloLinearNumExpr expr = lp.getModel().linearNumExpr();
		this.range.setExpr(expr);
	}
	
	public void put(OptK lp, int indexVar, double coef) throws IloException{
		IloNumVar var = lp.getVars().get(indexVar);
		((IloLinearNumExpr) range.getExpr()).addTerm(coef, var);
	}

	public IloRange getRange() {
		return range;
	}

	public void setRange(IloRange range) {
		this.range = range;
	}
	
	
	
}
